package com.enjoyor.soa.traffic.rest.efoms.dubbo.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.dto.efoms.DeviceWranInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.WranTacticsInfoDto;
import com.enjoyor.soa.traffic.api.service.dubbo.efoms.IDubboDeviceWranInfoService;
import com.enjoyor.soa.traffic.api.service.dubbo.efoms.IDubboWranTacticsService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IDeviceWranInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IWranTacticsConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.helper.CheckPojoHelper;
import com.enjoyor.soa.traffic.util.enums.EnumAppCode;
import com.enjoyor.soa.traffic.util.helper.ResultHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;

import java.util.List;

import org.springframework.stereotype.Component;

@Component
public class WranTacticsConsumeService implements IWranTacticsConsumeService {

    @Reference(version = "1.0.0", timeout = 10000)
    private IDubboWranTacticsService dubboWranTacticsService;
    
    /**
     * 根据策略编号查询设备策略信息
     * @param tacticsId 策略编号
     * @return ResultPojo
     */
    @Override
    public ResultPojo selectWranTacticsById(String tacticsId) {
    	ResultPojo resultPojo = new ResultPojo();
        try {
			resultPojo = dubboWranTacticsService.selectWranTacticsById(tacticsId);
        }catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }
    
    /**
     * 查询策略列表信息
     * @param tacticsId 策略编号
     * @param tacticsLevelCode 策略等级编号
     * @param wranTypeCode 报警类型编号
     * @param wranLevelCode 报警等级编号
     * @param devTypeCode 设备类型编号
     * @param devId 设备编号
     * @return ResultPojo
     */
    @Override
	public ResultPojo selectWranTacticsList(String tacticsId, String tacticsLevelCode, 
			String wranTypeCode, String wranLevelCode, String devTypeCode, String devId) {
    	ResultPojo resultPojo = new ResultPojo();
        try {
			resultPojo = dubboWranTacticsService.selectWranTacticsList(tacticsId, tacticsLevelCode, 
					wranTypeCode,wranLevelCode, devTypeCode, devId);
		}catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }
	/**
     * 新增策略信息
     * @param wranTacticsInfoDto
     * @param username 操作人
     * @return ResultPojo
     */
    @Override
    public ResultPojo insertWranTacticsInfo(WranTacticsInfoDto wranTacticsInfoDto, String username) {
    	ResultPojo resultPojo = new ResultPojo();
        try {
			resultPojo = dubboWranTacticsService.insertWranTacticsInfo(wranTacticsInfoDto, username);
		}catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }

    /**
     * 修改策略信息
     * @param wranTacticsInfoDto
     * @param username 操作人 
     * @return ResultPojo
     */
    @Override
    public ResultPojo updateWranTacticsInfo(WranTacticsInfoDto wranTacticsInfoDto, String username) {
    	ResultPojo resultPojo = new ResultPojo();
        try {
			resultPojo = dubboWranTacticsService.updateWranTacticsInfo(wranTacticsInfoDto, username);
		}catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }

    /**
     * 删除策略信息
     * @param tacticsId 策略编号
     * @param username 操作人
     * @return ResultPojo
     */
    @Override
    public ResultPojo deleteWranTacticsInfo(String tacticsId, String username) {
    	ResultPojo resultPojo = new ResultPojo();
        try {
			resultPojo = dubboWranTacticsService.deleteWranTacticsInfo(tacticsId, username);
		}catch (Exception e ){
            e.printStackTrace();
            return ResultHelper.getResult(e,EnumAppCode.OPERATOR_FAILURE);
        }
        return resultPojo;
    }
}
